/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       drag_artifact.h

	$Header: /game/drag_artifact.h $

	$NoKeywords: $

 ************************************************************************/
#ifndef DRAG_ARTIFACT_H_INCLUDED
#define DRAG_ARTIFACT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "artifact.h"
#include "artifact_icon.h"
#include "creature_stack.h"
#include "drag_object.h"
#include "game_window.h"

class   t_drag_artifact_source_holder;
enum	t_artifact_slot;
// -------------------------------------------------------------------
// window which holds an artifact which can be dragged away
// -------------------------------------------------------------------
class t_drag_artifact_source : public t_window
{
public:
	t_drag_artifact_source( t_screen_rect const& rect, 
		                    t_artifact_slot slot, 
							t_drag_artifact_source_holder* holder,
							t_window* parent );

	virtual bool		accept_drag( t_drag_object* drag, t_mouse_event const& event);
	void				drag_accepted( t_window * target ); 
	virtual void		drag_event( t_mouse_event const& event );
	t_artifact const&	get_artifact() const;
	int                 get_backpack_slot() const;
	t_artifact_slot		get_slot() const;
	t_creature_stack*	get_stack() const;
	void				restore( t_artifact const& artifact );
	void				set( t_artifact const& artifact, t_creature_stack* stack,
		                     int backpack_slot = -1 );
	void                update();
protected:
	t_artifact							m_artifact;
	int									m_backpack_slot;
	t_artifact_slot						m_slot;
	t_creature_stack_ptr				m_stack;
	t_drag_artifact_source_holder *		m_holder;
	t_counted_ptr<t_artifact_icon>		m_icon;
};

typedef t_counted_ptr< t_drag_artifact_source > t_drag_artifact_source_ptr;


inline t_artifact const& t_drag_artifact_source::get_artifact() const
{
	return m_artifact;
}

inline int t_drag_artifact_source::get_backpack_slot() const
{
	return m_backpack_slot;
}

inline t_artifact_slot t_drag_artifact_source::get_slot() const
{
	return m_slot;
}

inline t_creature_stack* t_drag_artifact_source::get_stack() const
{
	return m_stack;
}

// -------------------------------------------------------------------
// dragging class for artifacts
// -------------------------------------------------------------------
class t_drag_artifact : public t_drag_object
{
public:
	t_drag_artifact( t_artifact const& artifact, t_drag_artifact_source* source );
	virtual ~t_drag_artifact();

	virtual void				accepted( t_window* window );
	t_artifact&					get_artifact();
	t_drag_artifact_source_ptr	get_source();
protected:
	t_drag_artifact_source_ptr	m_source;
	t_artifact					m_artifact;
};

inline t_artifact& t_drag_artifact::get_artifact()
{
	return m_artifact;
}

inline t_drag_artifact_source_ptr t_drag_artifact::get_source() 
{
	return m_source;
}

#endif // DRAG_ARTIFACT_H_INCLUDED
